package o;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.graphics.drawable.Drawable;

public class fmw {
    public static Object ˏ(Context context, int i, String str) {
        Resources ˎ;
        int identifier;
        flr ˋ = flr.ˋ(context);
        Context ˏ = ˋ.ˏ();
        if (ˋ.ˋ()) {
            ˎ = ˋ.ˊ().ˎ();
            identifier = ˎ.getIdentifier(ˏ.getResources().getResourceEntryName(i), ˏ.getResources().getResourceTypeName(i), ˋ.ˊ().ˊ());
        } else {
            ˎ = ˏ.getResources();
            identifier = i;
        }
        Object obj = -1;
        switch (str.hashCode()) {
            case -2041409048:
                if (str.equals("color_state_list")) {
                    obj = 2;
                    break;
                }
                break;
            case -826507106:
                if (str.equals("drawable")) {
                    obj = null;
                    break;
                }
                break;
            case 94842723:
                if (str.equals("color")) {
                    obj = 1;
                    break;
                }
                break;
            case 95588145:
                if (str.equals("dimen")) {
                    obj = 3;
                    break;
                }
                break;
        }
        switch (obj) {
            case null:
                return ˊ(ˏ, ˎ, identifier, i);
            case 1:
                return ˏ(ˏ, ˎ, identifier, i);
            case 2:
                return ˋ(ˏ, ˎ, identifier, i);
            case 3:
                return ॱ(ˏ, ˎ, identifier, i);
            default:
                return null;
        }
    }

    public static Object ˊ(Context context, String str, String str2, String str3) {
        Resources ˎ;
        String ˊ;
        flr ˋ = flr.ˋ(context);
        Context ˏ = ˋ.ˏ();
        if (ˋ.ˋ()) {
            ˎ = ˋ.ˊ().ˎ();
            ˊ = ˋ.ˊ().ˊ();
        } else {
            ˎ = ˏ.getResources();
            ˊ = ˏ.getPackageName();
        }
        int identifier = ˎ.getIdentifier(str, str2, ˊ);
        int identifier2 = ˏ.getResources().getIdentifier(str, str2, ˏ.getPackageName());
        Object obj = -1;
        switch (str3.hashCode()) {
            case -2041409048:
                if (str3.equals("color_state_list")) {
                    obj = 2;
                    break;
                }
                break;
            case -826507106:
                if (str3.equals("drawable")) {
                    obj = null;
                    break;
                }
                break;
            case 94842723:
                if (str3.equals("color")) {
                    obj = 1;
                    break;
                }
                break;
            case 95588145:
                if (str3.equals("dimen")) {
                    obj = 3;
                    break;
                }
                break;
        }
        switch (obj) {
            case null:
                return ˊ(ˏ, ˎ, identifier, identifier2);
            case 1:
                return ˏ(ˏ, ˎ, identifier, identifier2);
            case 2:
                return ˋ(ˏ, ˎ, identifier, identifier2);
            case 3:
                return ॱ(ˏ, ˎ, identifier, identifier2);
            default:
                return null;
        }
    }

    private static Integer ˏ(Context context, Resources resources, int i, int i2) {
        Integer num = fkt.ॱ;
        flr ˋ = flr.ˋ(context);
        flo ˊ = ˋ.ˊ();
        Context ʼ = ˊ == null ? context : ˊ.ʼ();
        try {
            num = Integer.valueOf(fv.ˏ(resources, i, ʼ.getTheme()));
        } catch (NotFoundException e) {
        }
        if (num == fkt.ॱ) {
            try {
                num = Integer.valueOf(fv.ˏ(context.getResources(), i2, ʼ.getTheme()));
            } catch (NotFoundException e2) {
            }
        }
        if (!ˋ.ॱ() || num == null) {
            return num;
        }
        flq ॱ = fms.ˎ().ॱ();
        if ((num.intValue() & 16777215) != (ॱ.ˎ() & 16777215)) {
            return num;
        }
        return Integer.valueOf((ॱ.ˏ() & 16777215) | (num.intValue() & -16777216));
    }

    private static Drawable ˊ(Context context, Resources resources, int i, int i2) {
        Drawable drawable = null;
        flo ˊ = flr.ˎ().ˊ();
        Context ʼ = ˊ == null ? context : ˊ.ʼ();
        try {
            drawable = fv.ॱ(resources, i, ʼ.getTheme());
        } catch (NotFoundException e) {
        }
        if (drawable == null) {
            try {
                return fv.ॱ(context.getResources(), i2, ʼ.getTheme());
            } catch (NotFoundException e2) {
                fmq.ˎ("SkinManager.getDrawable failed to get origin drawable!");
            }
        }
        return drawable;
    }

    private static ColorStateList ˋ(Context context, Resources resources, int i, int i2) {
        ColorStateList ˎ = ˎ(context, resources, i, i2);
        if (ˎ != null && flr.ˋ(context).ॱ()) {
            flq ॱ = fms.ˎ().ॱ();
            ColorStateList ˎ2 = fmu.ˎ(ˎ, ॱ.ˎ(), ॱ.ˏ());
            if (ˎ2 != null) {
                return ˎ2;
            }
        }
        return ˎ;
    }

    private static ColorStateList ˎ(Context context, Resources resources, int i, int i2) {
        ColorStateList colorStateList = null;
        flo ˊ = flr.ˎ().ˊ();
        Context ʼ = ˊ == null ? context : ˊ.ʼ();
        try {
            colorStateList = fv.ˊ(resources, i, ʼ.getTheme());
        } catch (NotFoundException e) {
        }
        if (colorStateList != null) {
            return colorStateList;
        }
        Integer ˏ = ˏ(context, resources, i, i2);
        if (fkt.ॱ != ˏ) {
            return ColorStateList.valueOf(ˏ.intValue());
        }
        try {
            return fv.ˊ(context.getResources(), i2, ʼ.getTheme());
        } catch (NotFoundException e2) {
            return colorStateList;
        }
    }

    private static Integer ॱ(Context context, Resources resources, int i, int i2) {
        Integer num = null;
        try {
            num = Integer.valueOf(resources.getDimensionPixelSize(i));
        } catch (NotFoundException e) {
        }
        if (num == null) {
            try {
                num = Integer.valueOf(context.getResources().getDimensionPixelSize(i2));
            } catch (NotFoundException e2) {
            }
        }
        return num;
    }
}
